insert overwrite table mid.transactions
select transaction_id,cashier_id,sub_account_id,pos_id,transaction_number,transaction_date,period_id,tax_total,sale_total,bir_receipt_type,bir_trans_number,refunded,alt_transaction_number,cdraw_period_id,receipt_number,transaction_start_dt,award_total,redemption_total,refund_total,discount_total,refunded_date,is_refund,disc_as_mop_total,transaction_db_date,create_shijian,if(station_id = '58008','58010',station_id) station_id
from transactions;

insert overwrite table mid.transaction_items_oil
select transaction_id,item_number,item_type,tax_id,item_description,item_price,item_quantity,item_value,item_id,item_tax_amount,scitem,refunded,orig_trx_id,orig_item_num,department_id,item_ean,price_batch_id,group_item_type,group_parent_item_number,sub_item_number,currency_code,tax_rate,product_code,create_shijian,if(station_id = '58008','58010',station_id) station_id,transaction_date
from transaction_items_oil;

insert overwrite table mid.transaction_items_notoil
select transaction_id,item_number,item_type,tax_id,item_description,item_price,item_quantity,item_value,item_id,item_tax_amount,scitem,refunded,orig_trx_id,orig_item_num,department_id,item_ean,price_batch_id,group_item_type,group_parent_item_number,sub_item_number,currency_code,tax_rate,product_code,create_shijian,if(station_id = '58008','58010',station_id) station_id,transaction_date
from transaction_items_notoil;

insert overwrite table mid.products
select product_id,tax_id,department_id,product_desc,product_price,product_quick_code,product_code,product_ordering_status,product_managed_by,product_type,product_selling_type,product_stock_type,product_composite_type,multiple_taxes,price_batch_id,incomplete_product,delisted_date,product_special_type,barcode,upc_type,barcode_special_type,create_shijian,if(station_id = '58008','58010',station_id) station_id
from products;

insert overwrite table mid.departments
select id,department_id,dept_name,tax_id,dept_upper_halo,dept_lower_halo,dept_preset,dept_keynumber,dept_keylabel,dept_unit,dept_number,dept_level,dept_status,dept_managed_by,if(station_id = '58008','58010',station_id) station_id,dept_usage
from departments;

insert overwrite table mid.grades
select id,grade_id,grade_name,grade_number,price_profile_id,grade_description,allocation_limit,alloc_limit_type,oil_company_code,tax_link,group_link,delivery_timeout,price_pole_segment,grade_type,grade1_id,grade2_id,blend_ratio,min_price,max_price,loss_tolerance,gain_tolerance,is_enabled,deleted,volume_unit_id,gsapexport,if(station_id = '58008','58010',station_id) station_id
from grades;

insert overwrite table mid.future_grade_price
select future_grade_price_id,grade_id,effective_date,comment,price_type,grade_price,price_update_status,price_level,previous_grade_price,sequence_number,create_shijian,if(station_id = '58008','58010',station_id) station_id
from future_grade_price;

insert overwrite table mid.transaction_items_mop
select transaction_id,item_number,item_type,tax_id,item_description,item_price,item_quantity,item_value,item_id,item_tax_amount,scitem,refunded,orig_trx_id,orig_item_num,department_id,item_ean,price_batch_id,group_item_type,group_parent_item_number,sub_item_number,currency_code,tax_rate,mop_name,create_shijian,if(station_id = '58008','58010',station_id) station_id,transaction_date
from transaction_items_mop;

insert overwrite table mid.tbl_orderdetails
select orderdetails_id,version,nowdate,virtualgoodsid,returncode,litre,if(stationcode = '58008','58010',stationcode) stationcode,couponamount,requestid,ordernum,realamount,oilcode,order_deal,discountamount,carduserid,amount,oilprice,termnum,sendtime,invoicetitle,memberno,virtualgoodsids,customer_id,create_shijian,ppsordernumber,goodsamount,fuelcouponamount,goodcouponamount,goodscouponamount,updaterealamount,fulecouponamount,fuleamount,carlicense,oilgunno,order_state,epscode
from tbl_orderdetails;

insert overwrite table mid.tbl_orderdetails_cd
select orderdetails_id,version,nowdate,virtualgoodsid,returncode,litre,if(stationcode = '58008','58010',stationcode) stationcode,couponamount,requestid,ordernum,realamount,oilcode,order_deal,discountamount,carduserid,amount,oilprice,termnum,sendtime,invoicetitle,memberno,virtualgoodsids,customer_id,create_shijian,ppsordernumber,goodsamount,fuelcouponamount,goodcouponamount,goodscouponamount,updaterealamount,fulecouponamount,fuleamount,carlicense,oilgunno,order_state,epscode
from tbl_orderdetails_cd;


insert overwrite table mid.tbl_orderdetails_cd
select orderdetails_id,version,nowdate,virtualgoodsid,returncode,litre,if(stationcode = '58008','58010',stationcode) stationcode,couponamount,requestid,ordernum,realamount,oilcode,order_deal,discountamount,carduserid,amount,oilprice,termnum,sendtime,invoicetitle,memberno,virtualgoodsids,customer_id,create_shijian,ppsordernumber,goodsamount,fuelcouponamount,goodcouponamount,goodscouponamount,updaterealamount,fulecouponamount,fuleamount,carlicense,oilgunno,order_state,epscode
from tbl_orderdetails_cd;

insert overwrite table mid.hoses
select id,hose_id,pump_id,grade_id,tank_id,volume_total,tank2_id,hose_number,mechanical_total,money_total,theoretical_total,volume_total2,money_total2,theoretical_total2,blend_type,volume_total_turnover_correction,money_total_turnover_correction,volume_total2_turnover_correction,volume_total_state_id,money_total_state_id,volume_total2_state_id,deleted,volume_total1,money_total1,if(station_id = '58008','58010',station_id) station_id
from hoses;

insert overwrite table mid.hose_delivery
select delivery_id,hose_id,attendant_id,price_level,completed_ts,cleared_date_time,delivery_type,delivery_state,delivery_volume,delivery_value,del_sell_price,del_cost_price,cleared_by,reserved_by,transaction_id,del_item_number,delivery2_volume,hose_meter_volume,hose_meter_value,hose_meter_volume2,hose_meter_value2,auth_ref,blend_ratio,previous_delivery_type,delivery1_volume,delivery1_value,delivery2_value,hose_meter_volume1,hose_meter_value1,grade1_price,grade2_price,create_shijian,if(station_id = '58008','58010',station_id) station_id
from hose_delivery;

insert overwrite table mid.pumps
select id,pump_id,pump_type_id,pump_display_id,attendant_id,pump_profile_id,loop_id,pump_name,pump_description,logical_number,polling_address,serial_number,pump_history,price_1_level,price_2_level,reserved_by,reserve_state,auth_limit_type,auth_hose_mask,auth_limit,auth_level,price_multiplier,value_multiplier,deleted,tag_reader_installed,if(station_id = '58008','58010',station_id) station_id
from pumps;

insert overwrite table  mid.cashiers
select cashier_id,cashier_number,cashier_name,cashier_psw,cashier_type,attendant_id,cashier_disable,
cashier_birthdate,cashier_personal_name,cashier_family_name,user_role_id,if(station_id = '58008','58010',station_id) station_id,create_shijian
from cashiers;